import relief from 'data/relief.json';

const { layer, items, meta } = relief;

export const SIZE = 38;
export const ROW = layer.length; // 列 | y
export const COL = layer[0].length; // 行 | x
export const RELIEF = relief;

export default class MapCtrl {

    static getGridByPos(x, y) {
        let row = Math.floor(y / SIZE);
        let col = Math.floor(x / SIZE);
        if (!layer[row] || !layer[row][col])
            return null;
        let grid = {
            start: { x: col * SIZE, y: row * SIZE },
            end: { x: (col + 1) * SIZE, y: (row + 1) * SIZE },
            info: layer[row][col]
        };
        return grid;
    }

}